home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT05NEW.ZIP / TUT5.TXT < prev   
Text File  |  1994-12-28  |  11KB  |  238 lines

  1.                    ╒═══════════════════════════════╕
  2.                    │         W E L C O M E         │
  3.                    │  To the VGA Trainer Program   │ │
  4.                    │              By               │ │
  5.                    │      DENTHOR of ASPHYXIA      │ │ │
  6.                    │      (updated by Snowman)     │ │ │
  7.                    ╘═══════════════════════════════╛ │ │
  8.                      ────────────────────────────────┘ │
  9.                        ────────────────────────────────┘
  10.  
  11.                            --==[ PART 5 ]==--
  12.  
  13.  
  14. [Note: things in brackets have been added by Snowman.  The original text
  15. has remained mostly unaltered except for the inclusion of C++ material]
  16.  
  17. ■ Introduction
  18.  
  19. Hello! This is Denthor here with the 5 part of the ASPHYXIA VGA Trainer
  20. Series : The Scrolling Saga. I have had many requests for information on
  21. scrolling, so I decided to make it this weeks topic. Note that I do make
  22. reference to my recently released program TEXTER5, which should be available
  23. from wherever you get this message. (Note to Sysops : If you put the trainer
  24. series up on your boards, please add WORMIE.ZIP and TEXTER5.ZIP as they
  25. both suppliment this series)
  26.  
  27. By the way, sorry for the delay in the appearance of this part. Tests,
  28. projects and a few wild days of sin at the Wild Coast all conspired
  29. against the prompt appearance of this part. Also note I need more input as
  30. to what I should do future parts on, so leave me mail.
  31.  
  32. If you would like to contact me, or the team, there are many ways you
  33. can do it : 1) Write a message to Grant Smith in private mail here on
  34.                   the Mailbox BBS.
  35.             2) Write a message here in the Programming conference here
  36.                   on the Mailbox (Preferred if you have a general
  37.                   programming query or problem others would benefit from)
  38.             3) Write to ASPHYXIA on the ASPHYXIA BBS.
  39.             4) Write to Denthor, Eze or Livewire on Connectix.
  40.             5) Write to :  Grant Smith
  41.                            P.O.Box 270 Kloof
  42.                            3640
  43.                            Natal
  44.             6) Call me (Grant Smith) at 73 2129 (leave a message if you
  45.                   call during varsity)
  46.  
  47. NB : If you are a representative of a company or BBS, and want ASPHYXIA
  48.        to do you a demo, leave mail to me; we can discuss it.
  49. NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
  50.         quite lonely and want to meet/help out/exchange code with other demo
  51.         groups. What do you have to lose? Leave a message here and we can work
  52.         out how to transfer it. We really want to hear from you!
  53.  
  54.  
  55. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  56. ■  What is scrolling?
  57.  
  58. If you have ever seen a demo, you have probably seen some form of scrolling.
  59. Our SILKYDEMO has quite a nice example of scrolling. What it is is a long
  60. row of text moving across your screen, usually from right to left, eg :
  61.  
  62.                                        H     : Step 1
  63.                                       He     : Step 2
  64.                                      Hel     : Step 3
  65.                                     Hell     : Step 4
  66.                                    Hello     : Step 5
  67.                                   Hello      : Step 6
  68.  
  69. etc. etc. See the program attatched for an example of scrolling.
  70.  
  71. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  72. ■  What do we scroll?
  73.  
  74. Usually, letters. Most groups put greetings and information in their
  75. 'scrollies', as they are termed. You can also scroll and entire screen
  76. using the scrolling technique. Scrolling your text is a hell of a lot
  77. less boring then just having it appear on your screen. Unfortunately,
  78. 'scrollies' have been used so many times in demos they are wearing a
  79. bit thin, so usually they are accompanied by a cool picture or some nice
  80. routine happening at the same time (In our SILKYDEMO we had a moving
  81. checkerboard and colour bars going at the same time).
  82.  
  83. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  84. ■  How do we scroll from side to side?
  85.  
  86. The theory behind scrolling is quite easy. Let us imagine that we are
  87. scrolling a 16x16 font grabbed by TEXTER (;-)) across the top of the
  88. screen (ie. 320 pixels) As we know, the VGA screen starts at zero at the
  89. top left hand part of the screen, then counts up to the right to 319, then
  90. goes back to the left hand side one pixel down at 320. (See Tut 1) This means
  91. that a 16*320 scroller takes up the space 0 to 5119 on the screen. In ascii
  92. this looks like this :
  93.  
  94.             (0)   .                                    .  (319)
  95.             (320) .                                    .  (639)
  96.                             "             "           "
  97.            (4800) .                                    .   (5119)
  98.  
  99. Simple enough. Now what we do is we put down the first Y-line of the first
  100. character onto the very right hand side of the screen , like so :
  101.  
  102.   [Pascal]
  103.  
  104.               For loop1:=1 to 16 do
  105.                 Putpixel (319,loop1-1,font['A',1,loop1],vga);
  106.  
  107.   [C++]
  108.  
  109.               for (loop1=0; loop1<16; loop1++)
  110.                 Putpixel (319,loop1,Font['A'][0][loop1],vga);
  111.  
  112. This will draw some stuff on the very right hand side. Your screen should now
  113. look like this :
  114.  
  115.             (0)   .                                   X.  (319)
  116.             (320) .                                   X.  (639)
  117.                             "             "           "
  118.            (4800) .                                   X.   (5119)
  119.  
  120. Next, we move each line one to the left, ie :
  121.  
  122.   [Pascal]
  123.  
  124.               For loop1:=0 to 15 do
  125.                 Move   (mem[VGA:loop1*320+1], mem[VGA:loop1*320], 320);
  126.  
  127.   [C++]
  128.  
  129.               for (loop1=0; loop1<16; loop1++)
  130.                 memcpy (vga+(loop1*320)     , vga+(1+(loop1*320)),320);
  131.  
  132.  
  133. This scrolls the screen from right to left, which is the easiest to read.
  134. To scroll the screen from left to right, swap the +1 onto the other side
  135. of the command. Also, to increase the size of the portion scrolled, increase
  136. the 15 to however many lines from the top you wish to scroll-1.
  137.  
  138. After this move, your screen will look like this :
  139.  
  140.             (0)   .                                  X .  (319)
  141.             (320) .                                  X .  (639)
  142.                             "             "           "
  143.            (4800) .                                  X .   (5119)
  144.                                                       ^
  145.                                                 Note this space
  146.  
  147.  
  148. What you then do is draw in the next line on the right hand side, move it,
  149. draw the next line, move it etc. etc. Tah-Dah! You have a scrolly! Fairly
  150. simple, isn't it?
  151.  
  152. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  153. ■  How do we scroll up or down?
  154.  
  155. To scroll up or down is also fairly simple. This can be used for 'movie
  156. credit' endings (I once wrote a little game with a desert scrolling down
  157. with you being a little robot on the bottom of the screen). The theory is
  158. this : Draw the top line (or bottom line) then move the entire screen :
  159.  
  160.   [Pascal]
  161.  
  162.              Move  (mem[vga:0],mem[vga:320],63680);
  163.                        { 64000 - 320 = 63680 }
  164.  
  165.   [C++]
  166.  
  167.              memcpy (vga, vga+320, 63680);
  168.  
  169. For scrolling down, or :
  170.  
  171.   [Pascal]
  172.  
  173.              Move (mem[vga:320],mem[vga:0],63680);
  174.  
  175.   [C++]
  176.  
  177.              memcpy (vga+320, vga, 63680);
  178.  
  179. For scrolling up. You then draw the next line and repeat.
  180.  
  181. Because of the simplicity of coding in a scrolly, most demos have one. It
  182. is usually best to have something extra happening on the screen so that
  183. the viewer doesn't get too bored, even, as I say, if it is only a really nice
  184. picture.
  185.  
  186. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  187. ■  In closing
  188.  
  189. The University of Natal, Durban, Science Dept., now has 10 new 486's!
  190. This is a great boon, as now I can program nice routines during frees
  191. (even though I am a Commerce Student (Shhhhh) ;-) ). I can now use those
  192. previously wasted hours that I spent socialising and making friends
  193. coding instead ;-)
  194.  
  195. I suggest you get a copy of TEXTER, for coding demos with fonts, or in fact
  196. almost any graphics application, it is an amazing help, and we have used it
  197. for *ALL* our demos. (P.S. We have written many demos, but many have been
  198. written for companies and have not been released for the general public)
  199. NOTE : For TEXTER's test program TEST.PAS, add {$X+} {$R-} if you have range
  200. checking on (I code with it off.)
  201.  
  202.             [  "I'm from the Computer Inspection Agency, sir,
  203.                    I'm here to check your computer. Here is
  204.                    my identification."
  205.                "Certainly. Have a look, I'm clean. I don't have
  206.                    any pirated software."
  207.                The C-man pushes past him and sits in front of the
  208.                    computer. He notes the fact that the computer
  209.                    is currently off with a look of disdain. He
  210.                    makes a note on his clipboard. He boots up.
  211.                "What is this?" he asks, pointing at the screen.
  212.                "It's MasterMenu" stutters the man. "I wrote it
  213.                    myself!"
  214.                "Do you know what the penalty is for using junk
  215.                    like this on a private machine?" The C-man smiles.
  216.                    "This is a two-month sentance in itself!"
  217.                "I'm sorry sir! It won't happen again!"
  218.                "I know. I'll make sure of that." He smiles again.
  219.                The C-man runs through the hard drive, checking for
  220.                    illeagal software, bad programs and anti-government
  221.                    propaganda. He notes with satisfaction that he has
  222.                    enough to put this weenie away for ten years, not that
  223.                    it mattered. He usually could just make something up.
  224.                He comes to the last entry on the aphebetised menu tree.
  225.                    His hands jerk away from the keyboard. Then, tentatively,
  226.                    he types in the three letters of doom. He looks at the
  227.                    man, who is backing away with wide eyes and his hands
  228.                    outstretched in front of him, as if to ward off a blow.
  229.                The C-man smiles, his lips a thin, hard line.
  230.                "Windows!"
  231.                                                                      ]
  232.                                                            - Grant Smith
  233.                                                                1:55pm
  234.                                                                  16/9/93
  235.  
  236. Cheers,
  237.   - Denthor
  238.